package iit.projects.etaxi.model.entity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

public class SubCity implements Serializable {

	private static final long serialVersionUID = 3755510655748097498L;
	
	/**
	 * <p>Primary key of the Sub City</p>
	 */
	private Long id;
	
	/**
	 * <p>Sub city Code. Used for uniquely identifying a Sub City within a City</p>
	 */
	private String code;
	
	/**
	 * <p>Sub City name</p>
	 */
	private String name;
	
	/**
	 * <p>The City of which this sub city belongs to</p>
	 */
	private City city;
	
	/**
	 * <p>Contains the Sub Cities which are in proximity to this Sub City</p>
	 */
	private Set<SubCity> subCitiesInProximity = new HashSet<SubCity>(0);
	
	//private Set<SubCity> subCitiesToProximity = new HashSet<SubCity>(0);
	
	/**
	 * <p>The version of the sub city</p>
	 */
	private Long version;
	
	/**
	 * <p>The Key of the SubCity class</p>
	 */
	//private SubCityKey subCityKey;
	
	public SubCity() {
	}
	
	public SubCity(String code, String name) {
		this.code = code;
		this.name = name;
	}
	
	public SubCity(SubCity subCity) {
		this.id = subCity.id;
		this.code = subCity.code;
		this.name = subCity.name;
		this.city = subCity.city;
		this.version = subCity.version;
	}
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public City getCity() {
		return city;
	}

	public void setCity(City city) {
		this.city = city;
	}
	
	public Set<SubCity> getSubCitiesInProximity() {
		return subCitiesInProximity;
	}

	public void setSubCitiesInProximity(Set<SubCity> subCitiesInProximity) {
		this.subCitiesInProximity = subCitiesInProximity;
	}
	
//	public Set<SubCity> getSubCitiesToProximity() {
//		return subCitiesToProximity;
//	}
//
//	public void setSubCitiesToProximity(Set<SubCity> subCitiesToProximity) {
//		this.subCitiesToProximity = subCitiesToProximity;
//	}

	public Long getVersion() {
		return version;
	}

	public void setVersion(Long version) {
		this.version = version;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((getCity() == null) ? 0 : getCity().hashCode());
		result = prime * result + ((getCode() == null) ? 0 : getCode().hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		SubCity other = (SubCity) obj;
		if (getCity() == null) {
			if (other.getCity() != null)
				return false;
		} else if (!getCity().equals(other.getCity()))
			return false;
		if (getCode() == null) {
			if (other.getCode() != null)
				return false;
		} else if (!getCode().equals(other.getCode()))
			return false;
		return true;
	}

//	public SubCityKey getSubCityKey() {
//		return subCityKey;
//	}
//
//	public void setSubCityKey(SubCityKey subCityKey) {
//		this.subCityKey = subCityKey;
//	}


}
